package com.codefish.framework.spring.core.io.support;

import com.codefish.framework.spring.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.Properties;

/**
 * 属性资源加载工具类
 *
 * @author <a href='https://gitee.com/hzf2281'>codefish</a>
 * @version 1.0.0
 * @since 2022/11/04 下午 01:45
 */
public abstract class PropertiesLoaderUtils {

    /**
     * 从资源对象中加载属性
     *
     * @param properties 目标属性对象
     * @param resource   加载的资源对象
     */
    public static void fillProperties(Properties properties, Resource resource) {
        try (Reader reader = resource.getReader()) {
            properties.load(reader);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
